#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <unistd.h>
//模拟cat的实现
int main(int argc, char* argv[])
{
    if(argc!=2)
    {
        std::cerr<<"Usage: "<<argv[0]<<" filename"<<std::endl;
        exit(1);
    }
    FILE *fp = fopen(argv[1], "r");
    if (fp == NULL)
    {
        perror("fopen");
        exit(1);
    }
    char buf[1024] = {0};
    while (1)
    {
        size_t s = fread(buf, 1, sizeof(buf) - 1, fp);
        if (s > 0)
        {
            buf[s] = 0;
            printf("%s\n", buf);
        }   
    
        if (feof(fp))
        {
           
            break;
        }   

        sleep(10);
    }
    return 0;
}